home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / shell / command / src / main.c < prev   
Encoding:
C/C++ Source or Header  |  1995-05-28  |  2.9 KB  |  149 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <winb.h>
  5. #include <te.h>
  6. #include <fntb.h>
  7. #include <gui.h>
  8. #include <egb.h>
  9. #include <guidbg.h>
  10.  
  11. #include <KH.h>
  12.  
  13. //#define DEBUG
  14.  
  15. char    *guiEgbPtr ;            /*    EGB のワークアドレス    */
  16.  
  17. int    dialogID = -1 ;
  18. int    messageID[2] = -1 ;
  19.  
  20. char commandChar[129] ;    //    コマンド文字列
  21.  
  22. int userFunc(apliId, messId, info, data)
  23. int    apliId;
  24. int    messId;
  25. int    info;
  26. int    data;
  27. {
  28. /*    register int    ret;
  29.  
  30.     ret = ILLEGAL_FUNCTION;
  31.  
  32.     switch(messId)
  33.     {
  34.         case    GM_QUIT :
  35.             MMI_SetHaltFlag(TRUE);
  36.             ret = NOERR ;
  37.             break;
  38.     }
  39.  
  40. */    return ILLEGAL_FUNCTION;
  41. //    return(ret);
  42. }
  43.  
  44. void main(int argc,char *argv[])
  45. {
  46.     static MMICTRL mmi ={
  47.                 SCREEN16|SCREENIGNORE,        // ページ0側解像度
  48.                 SCREENUNUSED,                // ページ1側解像度
  49.                 0,                             // 書き込みページ
  50.                 SCREENAVAILABLE,             // 表示ページ
  51.                 0,                             // 表示プライオリティ
  52.                 SCREENAVAILABLE,            // 色数
  53.                 SCREENEXPAND,                 // VRAMの横の長さ
  54.                 0,                             // メモリ領域の大きさ
  55.                 NULL,                         // メモリ領域のアドレス
  56.                 0,                             // ユーザ領域の大きさ
  57.                 NULL,                         // ユーザ領域のアドレス
  58.                 0, 0,                         // 画面枠    lupx,lupy
  59.                 0, 0,                        //            rdwx,rdwy
  60.                 -16384, -16384,                // 移動枠    lupx,lupy
  61.                 16383, 16383,                //            rdwx,rdwy
  62.                 15,                         // 白色
  63.                 8,                          // 黒色
  64.                 7,                          // 灰色
  65.                 6                             // 反転色
  66.     };
  67.  
  68.     int i;
  69.  
  70.     if(argc<2) return ;
  71.  
  72.     commandChar[0] = '\0';
  73.  
  74.     for(i=1;i<argc;i++)
  75.     {
  76.         #ifdef DEBUG
  77.         printf("argv[%d]'%s'\n",i,argv[i]);
  78.         #endif
  79.         strcat(commandChar,argv[i]);
  80.         strcat(commandChar," \0");
  81.     }
  82.  
  83.     extern int APL_init() ;
  84.  
  85.     /*    初期化処理    */
  86.     if (MMI_Open( &mmi ) == NOERR)
  87.     {
  88.         /*    初期化に成功すればメインループに入る.    */
  89.         if (APL_init() == NOERR)
  90.             MMI_ExecSystem() ;
  91.     }
  92.  
  93.     /*    終了処理    */
  94.     MMI_Close() ;
  95.  
  96. }
  97.  
  98. int APL_init()
  99. {
  100.     extern MMIINIT    initDataCOMMAND ;
  101.  
  102.     int    ret,mret,mptr ;
  103.  
  104.     mret = MG_PushPtr(MB_WAIT,&mptr);        //    MB_WAIT==目覚まし時計
  105.  
  106.     /*    EGB ワークアドレスの取得.    */
  107.     guiEgbPtr = MMI_GetEgbPtr() ;
  108.  
  109.     /*    ハイパ型部品の初期化            */
  110.     if ((ret = MMI_initHyper()) < 0)
  111.         return ret ;
  112.     /*    ダイアログ型部品の初期化        */
  113.     if ((ret = MMI_initDialogL40()) < 0)
  114.         return ret ;
  115.     /*    メッセージ型部品の初期化        */
  116.     if ((ret = MMI_initMessageL40()) < 0)
  117.         return ret ;
  118.  
  119.     /*    背景データの初期化                        */
  120.  
  121.     /*    データの登録        */
  122.     if ((ret = MMI_Init(&initDataCOMMAND)) < 0)
  123.         return ret ;
  124.  
  125.     //    Tmenuにパレットを合わせる
  126.     KH_initGuiColor();
  127.  
  128.     /*    背景を表示する                            */
  129.     MMI_SendMessage(MMI_GetBaseObj(), MM_SHOW, 0) ;
  130.  
  131.     MMI_SendMessage(MMI_GetBaseObj(), MM_SETEXEC, 1, userFunc);
  132.     MMI_CallMessage(MMI_GetApliId(), GM_TITLE, (int)"コマンド実行しまっせ~          By 機拡", 0);
  133.  
  134.     //    コマンド実行
  135.     #ifdef DEBUG
  136.     printf("command'%s'\n",commandChar);
  137.     #endif
  138.     system( commandChar );
  139.  
  140.     //    消す
  141.     MMI_SendMessage(MMI_GetBaseObj(), MM_ERASE, 0) ;
  142.     //    終了フラグをたてる
  143.     MMI_SetHaltFlag(TRUE);
  144.  
  145.     if(mret==0) MG_PopPtr( mptr );
  146.  
  147.     return NOERR ;
  148. }
  149.